递归问题[C语言]

来源:百度知道 编辑:UC知道 时间:2024/05/05 15:35:14
#include<stdio.h>
void main()
{
void hanoi(int n,char one,char two,char three);
int m;
printf("input the number of diskes:");
scanf("%d",&m);
printf("The step to moveing %d diskes:\n",m);
hanoi(m,'A','B','C');
}
void hanoi(int n,char one,char two,char three)
{
void move(char x,char y);
if (n==1)
move(one,three);
else
{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
void move(char x,char y)
{
printf("%c-->%c\n",x,y);;
}

不用递归啊,没考虑过,汉诺塔问题好像书上都用作递归的经典范例讲啊,应该可以吧,可能麻烦点

汉诺塔问题
课本上有的

请问这个程序能不用递归写吗?

--楼主

这是什么问题啊
里面有很多的不足啊